package com.example.pc.videodemo;

import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;

import com.example.pc.videodemo.emq.MqttManager;

public class PhoneReceiver extends BroadcastReceiver
{
    public PhoneReceiver()
    {
    }


    @Override
    public void onReceive(Context context, Intent intent)
    {
        System.out.println("action" + intent.getAction());
//如果是去电
        if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL))
        {
            String phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
            Log.i("action", "call OUT:" + phoneNumber);
            MqttManager.Companion.getInstance().occupy();
//            Intent intent1  = new Intent(context,PhoneActivity.class);
//            intent1.putExtra("num",phoneNumber);
//            intent1.putExtra("type",1);
//            context.startActivity(intent1);
          /*  PhoneActivity.show(context, phoneNumber, new PhoneActivity.OnCallChangeListener()
            {
                @Override
                public void onAnswer()
                {

                }

                @Override
                public void onHangup()
                {

                }
            },1);*/
        }
        else
        {


//设置一个监听器
        }
    }

}
